package com.aaa.service.mht.impl;

import com.aaa.aspect.InsertAnn;
import com.aaa.aspect.UpdateAnn;
import com.aaa.entity.mht.QuestionMht;
import com.aaa.dao.mht.QuestionMhtDao;
import com.aaa.entity.PageSortEntity;
import com.aaa.service.mht.QuestionMhtService;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;


import javax.annotation.Resource;
import java.util.List;


@Service("QuestionMhtService")
public class QuestionMhtServiceImpl implements QuestionMhtService {
    @Resource
    private QuestionMhtDao questionMhtDao;


    @Override
    public Page queryAll(PageSortEntity pageSortEntity, QuestionMht questionMht) {
        //分页
        PageHelper.startPage(pageSortEntity.getPage(), pageSortEntity.getLimit(), pageSortEntity.getOrderString());
        List<QuestionMht> questionMhts = questionMhtDao.queryAll(questionMht);
        Page pageResult = (Page) questionMhts;
        return pageResult;
    }

    @InsertAnn
    @Override
    public boolean insert(QuestionMht questionMht) {
        return questionMhtDao.insert(questionMht);
    }

    @Override
    public boolean delete(List list) {
        return questionMhtDao.delete(list);
    }

    @UpdateAnn
    @Override
    public boolean update(QuestionMht questionMht) {
        return questionMhtDao.update(questionMht);
    }


    @Override
    public boolean repetitionId(QuestionMht questionMht) {
        Integer integer = this.questionMhtDao.repetitionId(questionMht);
        if (integer == 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean repetitionName(QuestionMht questionMht) {
        Integer integer = this.questionMhtDao.repetitionName(questionMht);
        if (integer == 0) {
            return true;
        }
        return false;
    }
}
